package cn.aitrox.ry.service.anno.dao.impl;

import cn.aitrox.ry.common.dao.MapperSqlCallback;
import cn.aitrox.ry.common.dao.impl.BaseDaoImpl;
import cn.aitrox.ry.service.anno.dao.AnnoComponentDao;
import cn.aitrox.ry.service.anno.entity.AnnoComponentEntity;
import cn.aitrox.ry.service.anno.mapper.AnnoComponentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AnnoComponentDaoImpl extends BaseDaoImpl<AnnoComponentEntity> implements AnnoComponentDao {

    @Autowired
    private AnnoComponentMapper mapper;

    @Override
    public List<AnnoComponentEntity> findByTaskId(Integer taskId) {

        AnnoComponentEntity cond = new AnnoComponentEntity();
        cond.setTaskId(taskId);

        return findByCondition(cond, null);
    }

    @Override
    public void batchSave(List<AnnoComponentEntity> list) {
        batchInsert(list, 1000, new MapperSqlCallback<AnnoComponentEntity>() {
            @Override
            public void batchInsert(List<AnnoComponentEntity> objList) {
                mapper.batchInsert(objList);
            }
        });
    }

    @Override
    public void deleteByTaskId(Integer taskId) {
        mapper.deleteByTaskId(taskId);
    }
}
